package com.hkbigdata.sybx.controller;

import com.hkbigdata.sybx.bean.DietRecord;
import com.hkbigdata.sybx.bean.ExerciseLog;
import com.hkbigdata.sybx.bean.RestSchedule;
import com.hkbigdata.sybx.service.StateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author liuanbo
 * @creat 2025-06-05-18:46
 * @see 2194550857@qq.com
 */
@RestController
@RequestMapping("/api/state")
public class StateController {
    @Autowired
    private StateService stateService;

    // 饮食记录接口
    @GetMapping("/DietRecord")
    public List<DietRecord> getDietRecord() {
        return stateService.getDietRecord();
    }

    @GetMapping("/DietRecord/{dietId}")
    public DietRecord getDietRecordById(@PathVariable Long dietId) {
        return stateService.getDietRecordById(dietId);
    }

    @PostMapping("/DietRecord")
    public int insertDietRecord(@RequestBody DietRecord dietRecord) {
        return stateService.insertDietRecord(dietRecord);
    }

    @PutMapping("/DietRecord")
    public int updateDietRecord(@RequestBody DietRecord dietRecord) {
        return stateService.updateDietRecord(dietRecord);
    }

    @DeleteMapping("/DietRecord/{dietId}")
    public int deleteDietRecord(@PathVariable Long dietId) {
        return stateService.deleteDietRecord(dietId);
    }

    // 作息记录接口
    @GetMapping("/RestSchedule")
    public List<RestSchedule> getRestSchedule() {
        return stateService.getRestSchedule();
    }

    @GetMapping("/RestSchedule/{scheduleId}")
    public RestSchedule getRestScheduleById(@PathVariable Long scheduleId) {
        return stateService.getRestScheduleById(scheduleId);
    }

    @PostMapping("/RestSchedule")
    public int insertRestSchedule(@RequestBody RestSchedule restSchedule) {
        return stateService.insertRestSchedule(restSchedule);
    }

    @PutMapping("/RestSchedule")
    public int updateRestSchedule(@RequestBody RestSchedule restSchedule) {
        return stateService.updateRestSchedule(restSchedule);
    }

    @DeleteMapping("/RestSchedule/{scheduleId}")
    public int deleteRestSchedule(@PathVariable Long scheduleId) {
        return stateService.deleteRestSchedule(scheduleId);
    }

    // 运动记录接口
    @GetMapping("/ExerciseLog")
    public List<ExerciseLog> getExerciseLog() {
        return stateService.getExerciseLog();
    }

    @GetMapping("/ExerciseLog/{exerciseId}")
    public ExerciseLog getExerciseLogById(@PathVariable Long exerciseId) {
        return stateService.getExerciseLogById(exerciseId);
    }

    @PostMapping("/ExerciseLog")
    public int insertExerciseLog(@RequestBody ExerciseLog exerciseLog) {
        return stateService.insertExerciseLog(exerciseLog);
    }

    @PutMapping("/ExerciseLog")
    public int updateExerciseLog(@RequestBody ExerciseLog exerciseLog) {
        return stateService.updateExerciseLog(exerciseLog);
    }

    @DeleteMapping("/ExerciseLog/{exerciseId}")
    public int deleteExerciseLog(@PathVariable Long exerciseId) {
        return stateService.deleteExerciseLog(exerciseId);
    }
}